var grid;
$(function(){

    grid = $('#table-grid').abelGrid({
        url:ctx+'/admin/user/ajaxDataGrid',
        pageSize:5
    })
})

function doSearch(){
    grid.reLoad($('#search-form').serialize());
}

function enabledFmt(val){
    var fmt = '否';
    if(val == 1){
        fmt = '是';
    }
    return fmt;
}

function operFmt(val){
    return '<a href="'+ctx+'/admin/user/edit/'+val+'">编辑</a> | '
        + '<a href="javascript:doDel(\''+val+'\');">删除</a>';
}

function doDel(id){
    layer.confirm('确定删除该记录？', {
        btn: ['确定','取消'] //按钮
    }, function(i){
        $.ajax({
            type:'post',
            url:ctx+'/admin/user/doDel',
            data:{id:id},
            dataType:'json',
            success:function(resp){
                doSearch();
            }
        })
        layer.close(i)
    }, function(i){
        layer.close(i)
    });
}

